/**
 * @param {string} s
 * @param {string} p
 * @param {number[]} removable
 * @return {number}
 */
 var maximumRemovals = function(s, p, removable) {
    const check = (t, s) => {
        if (s.length === 0) return true;
        let indexS = 0,
            indexT = 0;
        while (indexT < t.length) {
            if (s[indexS] === t[indexT]) {
                indexS++;
                if (indexS > s.length - 1) return true;
            }
            indexT++;
        }
        return false;
    };
    const getStr = (idx) => {
        let temp = s.split('')
        for(let i = 0; i<idx; i++){
            temp[removable[i]] = ''
        }
        return temp.join('')
    }    
    let l = 0, r = removable.length
    while(l <= r){
        let m = (l+r) >>1
        let ss = getStr(m)
        if(check(ss, p)){
            l = m+1
        }else{
            r = m-1
        }
    }
    return r
};